package com.gaswell.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gaswell.mapper.*;
import com.gaswell.pojo.ALLQj;
import com.gaswell.service.ALLQjService;
import com.gaswell.service.IQaa01Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

@Service
@DS("mysql")
public class ALLQjServiceImpl extends ServiceImpl<ALLQjMapper, ALLQj> implements ALLQjService {
    private static List<String> jhList;
    @Autowired
    private QjMapper qjMapper;
    @Autowired
    private RscsjMapper rscsjMapper;
    @Autowired
    private YscsjMapper yscsjMapper;
    @Autowired
    RealTimeDataMapper realTimeDataMapper;
    @Autowired
    private IQaa01Service qaa01Service;

    @Override
    public List<String> findZwjh(String ym) {
        List<String> strings = new LinkedList<>();
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (ym != null)
            allQjLambdaQueryWrapper.eq(ALLQj::getYm, ym);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getZwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public List<String> findZwjh(String ym, int sfszh) {
        List<String> strings = new LinkedList<>();
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (ym != null)
            allQjLambdaQueryWrapper.eq(ALLQj::getYm, ym);
        allQjLambdaQueryWrapper.eq(ALLQj::getSfszhjs, sfszh);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getZwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public List<ALLQj> findZwjhAndYwjh(List<String> jhs) {
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        allQjLambdaQueryWrapper.in(ALLQj::getZwbh, jhs).or().in(ALLQj::getYwbh, jhs);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        return allQjs;
    }

    @Override
    public List<String> findYwjh(String ym) {
        List<String> strings = new LinkedList<>();
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        if (ym != null)
            allQjLambdaQueryWrapper.eq(ALLQj::getYm, ym);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getYwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public List<String> findYwjh(String ym, int sfszh) {
        List<String> strings = new LinkedList<>();

        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        allQjLambdaQueryWrapper.eq(ALLQj::getSfszhjs, sfszh);
        if (ym != null)
            allQjLambdaQueryWrapper.eq(ALLQj::getYm, ym);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getYwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public List<String> finywbhdszhjs(int state) {
        List<String> strings = new LinkedList<>();
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        allQjLambdaQueryWrapper.eq(ALLQj::getSfszhjs, state);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getYwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public List<String> finywbhdnotszhjs(int state) {
        List<String> strings = new LinkedList<>();
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getYwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public List<String> finzwbhdnotszhjs(int state) {
        List<String> strings = new LinkedList<>();
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getZwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public List<String> finzwbhdszhjs(int state) {
        List<String> strings = new LinkedList<>();
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        allQjLambdaQueryWrapper.eq(ALLQj::getSfszhjs, state);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        if (allQjs != null && allQjs.size() > 0) {
            allQjs.forEach(
                    qj -> {
                        strings.add(qj.getZwbh());
                    }
            );
        }
        return strings;
    }

    @Override
    public ALLQj findOne(String jh) {
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        allQjLambdaQueryWrapper.eq(ALLQj::getYwbh, jh).or().eq(ALLQj::getZwbh, jh);
        ALLQj allQj = baseMapper.selectOne(allQjLambdaQueryWrapper);
        return allQj;
    }

    @Override
    public List<ALLQj> findList(String[] jhs) {
        LambdaQueryWrapper<ALLQj> allQjLambdaQueryWrapper = new LambdaQueryWrapper<>();
        allQjLambdaQueryWrapper.in(ALLQj::getZwbh, jhs).or().in(ALLQj::getYwbh, jhs);
        List<ALLQj> allQjs = baseMapper.selectList(allQjLambdaQueryWrapper);
        return allQjs;
    }
}
